/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Excersize2_Swing;

import Excersize2_Swing.SwingConstants.BattleshipTypes;
import battleshipgame.logic.Board;
import battleshipgame.logic.Player.Direction;
import battleshipgame.logic.Battleship;
import battleshipgame.logic.Player;

/**
 *
 * @author אלירן
 * this class is for containing ship insert commands
 */
public class CommandSetnUnSetBattleship extends SwingCommand {

    boolean enabled;
    private String coordinate;
    private int BattleshipSize;
    private Direction direction;
    private Player player;
    private SwingConstants.BattleshipTypes battleshipTypes;
    private Battleship battleship;
    //BattleshipGameJFrame referBattleshipGameJFrame;

    public boolean IsEnabled() {
        return enabled;
    }

    public BattleshipTypes getBattleshipTypes() {
        return battleshipTypes;
    }

    public void setBattleshipType(BattleshipTypes battleshipTypes) {
        this.battleshipTypes = battleshipTypes;
    }

//    public CommandSetnUnSetBattleship(DO_OR_UNDO do_or_undo, BattleshipGameJFrame referBattleshipGameJFrame) { //at first we only know which battleship was cosen
//        enabled = false;
//        this.referBattleshipGameJFrame = referBattleshipGameJFrame;
//    }

    public CommandSetnUnSetBattleship(DO_OR_UNDO do_or_undo, BattleshipGameJFrame referBattleshipGameJFrame) {
        super(do_or_undo, referBattleshipGameJFrame);
        enabled = false;
        this.referBattleshipGameJFrame = referBattleshipGameJFrame ;
    }

    
    public CommandSetnUnSetBattleship(DO_OR_UNDO do_or_undo,
            BattleshipGameJFrame referBattleshipGameJFrame, String coordinate,
            int BattleshipSize, Direction direction, BattleshipTypes battleshipTypes , Player player , Battleship battleship) {
        super(do_or_undo, referBattleshipGameJFrame);
        this.player = player;
        this.battleship = battleship;
        this.do_or_undo = do_or_undo;
        this.coordinate = coordinate;
        this.BattleshipSize = BattleshipSize;
        this.direction = direction;
        this.battleshipTypes = battleshipTypes;
        enabled = true;
    }

    public void setBattleshipTypes(BattleshipTypes battleshipTypes) {
        this.battleshipTypes = battleshipTypes;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public int getBattleshipSize() {
        return BattleshipSize;
    }

    public String getCoordinate() {
        return coordinate;
    }

    public Direction getDirection() {
        return direction;
    }

    public void setBattleshipSize(int BattleshipSize) {
        this.BattleshipSize = BattleshipSize;
    }

    public void setCoordinate(String coordinate) {
        this.coordinate = coordinate;
    }

    public void setDirection(Direction direction) {
        this.direction = direction;
    }

    @Override
    void RevertCommand() {
        if (this.do_or_undo == SwingCommand.DO_OR_UNDO.DO) {
            referBattleshipGameJFrame.changePlayerFocus(player.getId());
            referBattleshipGameJFrame.removeBattleshipFromBoard(battleship);           
        } else {
            referBattleshipGameJFrame.changePlayerFocus(player.getId());
            referBattleshipGameJFrame.SetBattleshipInBoard(this);
        }
    }

    public void setBattleship(Battleship battleship) {
        this.battleship = battleship;
    }

    public void setPlayer(Player player) {
        this.player = player;
    }
}
